<template>
  <div class="gexi-box">
    <div class="top">
      <!-- 走马灯 -->
      <el-carousel :interval="4000" type="card" height="200px">
        <el-carousel-item v-for="(item, index) in lunblost" :key="index">
          <!-- <h3 class="medium">{{ item }}</h3> -->
          <img :src="item.imageUrl" alt="" />
        </el-carousel-item>
      </el-carousel>
    </div>
    <!-- 推荐歌单 -->
    <div class="recomment-list">
      <div class="top flex">
        <div class="fs20">推荐歌单</div>
        <div>更多</div>
      </div>
      <div class="listMusic flex-one">
        <!-- v-for -->
        <div class="item" v-for="(item, index) in playlists" :key="index">
          <div class="item-top">
            <div class="play-num">
              <i class="el-icon-service">{{ item.commentCount }}</i>
            </div>
            <div class="top-name">666</div>
            <img :src="item.coverImgUrl" alt="" />
            <div class="playMusic"><i class="el-icon-video-play"></i></div>
          </div>
          <div>{{ item.name }}</div>
        </div>
      </div>
    </div>
    <!-- 独家 -->
    <div class="exclusive-list">
      <div class="top flex">
        <div class="fs20">独家放送</div>
        <div>更多</div>
      </div>
      <div class="listMusic flex-one">
        <!-- v-for -->
        <div class="item" v-for="(item, index) in result" :key="index">
          <div class="item-top">
            <img :src="item.picUrl" alt="" />
            <div class="playMusic"><i class="el-icon-video-play"></i></div>
          </div>
          <div>{{ item.name }}</div>
        </div>
      </div>
    </div>
    <!-- 最新音乐 -->
    <div class="newMusic-list">
      <div class="top flex">
        <div class="fs20">最新音乐</div>
        <div>更多</div>
      </div>
      <div class="listMusic flex-one">
        <div class="item" v-for="(item, index) in newResult" :key="index">
          <el-card shadow="hover">
            <div class="new-item flex-two">
              <div v-if="index < 9">0{{ index + 1 }}</div>
              <div v-else>{{ index + 1 }}</div>
              <div class="img">
                <div class="playMusic"><i class="el-icon-video-play"></i></div>
                <img :src="item.picUrl" alt="" />
              </div>
              <div>
                <div>{{ item.name }}</div>
                <div>{{ item.alg }}</div>
              </div>
            </div>
          </el-card>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getLunbo,
  getListMusic,
  getexclusive,
  getNewMusin,
} from "@/network/gexin.js";
export default {
  name: "Gexi",
  data() {
    return {
      lunblost: [],
      playlists: [],
      result: [],
      newResult: [],
    };
  },
  created() {
    //获取网络请求
    this.getLunbo();
    this.getListMusicM();
    this.getexclusiveM();
    this.getNewMusinM();
  },
  methods: {
    //获取走马灯的方法
    getLunbo() {
      getLunbo("/banner ").then((res) => {
        // console.log(res);
        this.lunblost = res.banners;
      });
    },
    //获取歌单
    getListMusicM() {
      getListMusic("/top/playlist", { limit: 10 }).then((res) => {
        // console.log(res);
        this.playlists = res.playlists;
      });
    },
    //获取独家接口
    getexclusiveM() {
      getexclusive("/personalized/privatecontent").then((res) => {
        // console.log(res);
        this.result = res.result;
      });
    },
    //最新音乐
    getNewMusinM() {
      getNewMusin("personalized/newsong").then((res) => {
        console.log(res);
        this.newResult = res.result;
      });
    },
  },
};
</script>

<style scoped lang="less">
//走马灯样式
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

//
.gexi-box {
  //推荐
  .recomment-list {
    .top {
      height: 40px;
      border-bottom: 2px solid blue;
      margin-bottom: 16px;
    }
    .listMusic {
      padding: 0 60px;
      .item {
        height: 250px;
        width: 200px;
        margin-right: 20px;

        overflow: hidden;
        .item-top {
          position: relative;
          height: 200px;
          width: 200px;
          .play-num {
            position: absolute;
            right: 0;
            width: 100px;
            height: 12px;
            font-size: 8px;
            padding-right: 20px;
            text-align: right;
            color: #fff;
            background: rgba(19, 18, 18, 0.5);
          }
          img {
            height: 100%;
            width: 100%;
          }
          .top-name {
            position: absolute;
            width: 200px;
            height: 20px;
            line-height: 20px;
            font-size: 10px;
            text-align: left;
            color: #fff;
            background: rgba(19, 18, 18, 0.5);
            transform: translateY(-100%);
            transition: transform 0.4s;
          }
          .playMusic {
            position: absolute;
            right: 10px;
            bottom: 18px;
            width: 50px;
            height: 50px;
            font-size: 50px;
            border-radius: 50%;
            color: red;
            transform: translateX(115%);
            transition: transform 0.4s;
          }
        }
      }
      .item:hover .top-name {
        transform: translateY(0);
      }
      .item:hover .playMusic {
        transform: translateX(0);
      }
    }
  }
  //exclusive 独家
  .exclusive-list {
    .top {
      height: 40px;
      border-bottom: 2px solid blue;
      margin-bottom: 16px;
    }
    .listMusic {
      padding: 0 115px;
      .item {
        height: 226px;
        width: 310px;
        overflow: hidden;
        margin-right: 20px;
        .item-top {
          position: relative;
          height: 174px;
          width: 310px;
          img {
            height: 100%;
            width: 100%;
          }
          .playMusic {
            position: absolute;
            right: 10px;
            bottom: 18px;
            height: 50px;
            width: 50px;
            border-radius: 50%;
            font-size: 50px;
            color: red;
            transform: translateX(115%);
            transition: transform 0.4s;
          }
        }
      }
      .item:hover .top-name {
        transform: translateY(0);
      }
      .item:hover .playMusic {
        transform: translateX(0);
      }
    }
  }
  //最新音乐
  .newMusic-list {
    .top {
      height: 40px;
      border-bottom: 2px solid blue;
      margin-bottom: 16px;
    }
    .listMusic {
      padding: 0 50px;
      .item {
        width: 50%;
        .new-item {
          height: 60px;
          .img {
            position: relative;
            .playMusic {
              position: absolute;
              right: 20px;
              bottom: 0;
              height: 40px;
              width: 40px;
              font-style: 30px;
              color: orange;
            }
            img {
              width: 100px;
              height: 60px;
              margin-left: 20px;
              margin-right: 22px;
            }
          }
        }
      }
    }
  }
}
</style>